package com.am;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Component;
import java.net.URL;
 
import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.RealizeCompleteEvent;
 
public class PlayerApplet extends Applet implements ControllerListener {
       /**
        * Playing an MPEG Movie in an Applet
        */
       private static final long serialVersionUID = 1L;
 
       Player player = null;
 
       public void init() {
              setLayout(new BorderLayout());
//              MediaLocator mrl = new MediaLocator(new java.lang.String(
//                            "file:D:/TDDOWNLOAD/aa.avi"));
//              
              URL url = null;
        
                 
      
              
              try {
            	     url = new URL("file:D:/TDDOWNLOAD/aa.avi");
       
                     player = Manager.createPlayer(url);
                     System.out.println("test1:" + player);
                     player.addControllerListener(this);
              } catch (Exception e) {
                     System.err.println("Got exception " + e);
              }
       }
 
       public void start() {
              player.start();
       }
 
       public void stop() {
              player.stop();
              player.deallocate();
       }
 
       public void destroy() {
              player.close();
       }
 
       public synchronized void controllerUpdate(ControllerEvent event) {
              if (event instanceof RealizeCompleteEvent) {
                     Component comp;
                     if ((comp = player.getVisualComponent()) != null)
                            add("Center", comp);
                     if ((comp = player.getControlPanelComponent()) != null)
                            add("South", comp);
                     validate();
              }
       }
}